<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"  
                xmlns:h="http://java.sun.com/jsf/html"  
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../templates/StaffTemplate.xhtml">

    <ui:define name="nav_menu">
        <p:menubar model="#{staffChangeInitialPasswordManagedBean.staffMenuModel}"/>
    </ui:define>
    <ui:define name="content">               
        <p:fieldset>
            <h2>View Groupon Purchase Information</h2>
            <br/>
            <h:outputText value="GROUPON NAME : #{grouponManagerBean.selectedGroupon.groupon.name}" style="font-weight:bold; text-align:center; font-size:14px"/>
            <br/>
            <br/>
            <h:outputText value="OFFERED BY : #{grouponManagerBean.selectedGroupon.groupon.stakeholder.corpName}" style="font-weight:bold; text-align:center; font-size:14px"/>
            <br/>
            <br/>
            <p:accordionPanel autoHeight="false">
                <p:tab title="List of Groupon Purchasers">
                    <p:dataTable var="purchase" value="#{grouponManagerBean.grouponPurchaseList}" paginator="true" 
                                 rows="10" emptyMessage="No purchase information found" 
                                 selectionMode="single" dblClickSelect="true">
                        <p:column sortBy="#{purchase.id}" filterBy="#{purchase.id}">
                            <f:facet name="header">
                                <h:outputText value="ID" />
                            </f:facet>
                            <h:outputText value="#{purchase.id}" />
                        </p:column>

                        <p:column sortBy="#{purchase.confirmationId}" filterBy="#{purchase.confirmationId}">
                            <f:facet name="header">
                                <h:outputText value="Confirmation ID" />
                            </f:facet>
                            <h:outputText value="#{purchase.confirmationId}" />
                        </p:column>

                        <p:column sortBy="#{purchase.groupon.offeredPrice}" filterBy="#{purchase.groupon.offeredPrice}">
                            <f:facet name="header">
                                <h:outputText value="Offered Price" />
                            </f:facet>
                            <h:outputText value="#{purchase.groupon.offeredPrice} SGD" />
                        </p:column>

                        <p:column sortBy="#{purchase.quantity}" filterBy="#{purchase.quantity}">
                            <f:facet name="header">
                                <h:outputText value="Quantity" />
                            </f:facet>
                            <h:outputText value="#{purchase.quantity}" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Image" />
                            </f:facet>
                            <p:graphicImage id="imageDisplay" value="/images/upload/media/#{purchase.groupon.imageURL}"
                                            height="50" width="70"/> 
                        </p:column>  

                        <p:column sortBy="#{purchase.tourist.tourist.firstName} #{purchase.tourist.tourist.lastName}" filterBy="#{purchase.tourist.tourist.firstName} #{purchase.tourist.tourist.lastName}">
                            <f:facet name="header">
                                <h:outputText value="Customer name" />
                            </f:facet>
                            <h:outputText value="#{purchase.tourist.tourist.firstName} #{purchase.tourist.tourist.lastName}" />
                        </p:column>

                        <p:column sortBy="#{purchase.transactions.get(0).datePaid}" filterBy="#{purchase.transactions.get(0).datePaid}">
                            <f:facet name="header">
                                <h:outputText value="Purchase Date" />
                            </f:facet>
                            <h:outputText value="#{purchase.transactions.get(0).datePaid}">
                                <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                            </h:outputText>
                        </p:column>

                        <p:column sortBy="#{purchase.status}" filterBy="#{purchase.status}">
                            <f:facet name="header">
                                <h:outputText value="Status" />
                            </f:facet>
                            <h:outputText value="#{purchase.status}" />
                        </p:column>
                    </p:dataTable>
                </p:tab>
            </p:accordionPanel> 
        </p:fieldset>
    </ui:define>
</ui:composition>